<?php

require_once 'common/conn.php';
require_once 'common/common.php';

$data = array();
// type = question || answer || voice || letter
if (isset($_GET['version']) && isset($_GET['type']) && isset($_GET['os'])) {
    $version = intval(trim($_GET['version']) * 10);
    $type = trim($_GET['type']);
    $os = trim($_GET['os']);

    $db = new DBC();
    $sql = "SELECT * FROM t_hibaby_resource_version WHERE name = '" . $type . "' AND version*10 >'" . $version . "' AND os = '" . $os . "'";
    $temp = $db->fetchData($sql);
    if (checkArrayNotEmpty($temp)) {
        $data['totalNumber'] = "1";
    } else {
        $data['totalNumber'] = "0";
    }
    /*
      if (isset($type) && $type == "question") {
      $sql = "SELECT COUNT(code) AS totalNumber FROM t_game_question WHERE version*10 > '" . $version . "'";
      $data = $db->fetchData($sql);
      } else if (isset($type) && $type == "answer") {
      $sql = "SELECT COUNT(code) AS totalNumber FROM t_game_answer WHERE version*10 > '" . $version . "'";
      $data = $db->fetchData($sql);
      } else if (isset($type) && $type == "voice") {
      $sql = "SELECT COUNT(code) AS totalNumber FROM t_game_resource_voice WHERE version*10 > '" . $version . "'";
      $data = $db->fetchData($sql);
      } else if (isset($type) && $type == "letter") {
      $sql = "SELECT COUNT(code) AS totalNumber FROM t_game_answer WHERE version*10 > '" . $version . "'";
      $data = $db->fetchData($sql);
      }
     */
}

echo json_encode($data);
?>